package net.siufung.market.base.permit.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.siufung.core.model.EnumsVo;
import net.siufung.core.model.IEnum;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 陈建峰
 * @since 2021/11/16 9:51 上午
 */
@ToString
@AllArgsConstructor
public enum PermitTypes implements IEnum<String> {

    /**
     * 链接
     */
    LINK("0", "链接"),
    /**
     * 按钮
     */
    BUTTON("1", "按钮");

    @Getter
    @Setter
    private String value;

    @Getter
    @Setter
    private String desc;

    public static PermitTypes get(String value) {
        return IEnum.get(PermitTypes.class,
                enums -> enums.getValue().equals(value));
    }

    public static String getDesc(String value) {
        return IEnum.getDesc(PermitTypes.class,
                enums -> enums.getValue().equals(value));
    }

    public static List<EnumsVo> getList(){
        return IEnum.findList(PermitTypes.class).stream()
                .map(element -> new EnumsVo(element.getValue(), element.getDesc()))
                .collect(Collectors.toList());
    }
}
